package com.ktwlsoft.archivemanage.controller.dataProfile;

import com.ktwlsoft.archivemanage.domain.business.repositoryService.view.TransferDataProfileRepositoryService;
import com.ktwlsoft.archivemanage.payload.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.Year;

@Api(description = "档案移交数据分析")
@RestController
@RequestMapping("/transferDataProfile")
public class TransferDataProfileController {

    private final TransferDataProfileRepositoryService transferDataProfileRepositoryService;

    public TransferDataProfileController(TransferDataProfileRepositoryService transferDataProfileRepositoryService) {
        this.transferDataProfileRepositoryService = transferDataProfileRepositoryService;
    }

    @ApiOperation("年度总移交量的历史变化趋势")
    @GetMapping("/getTotalTransferOfYear")
    public ResponseEntity<?> getTotalTransferOfYear(){
        return ResponseEntity.ok(Result.ok(transferDataProfileRepositoryService.getUnitArchiveReportMapper().findTotalTransferOfYears()));
    }

    @ApiOperation("移交进度统计")
    @GetMapping("/getProgressStatistic")
    public ResponseEntity<?> getProgressStatistic(@ApiParam("年度") @RequestParam Year year){
        return ResponseEntity.ok(Result.ok(transferDataProfileRepositoryService.getProgressStatistic(year)));
    }

    @GetMapping("/getTotalTransferOfUnit")
    public ResponseEntity<?> getTotalTransferOfUnit(@ApiParam("单位Id") @RequestParam Long unitId) {
        return ResponseEntity.ok(Result.ok(transferDataProfileRepositoryService.getUnitArchiveReportMapper().findTotalTransferOfYearsOfUnit( unitId)));
    }
}
